<?php
class StoryAction extends Action {
	public function storyList() {
		//防止页面乱码  
		header ( "Content-Type:text/html; charset=utf-8" );
		$Story = M('Story'); 
		$list = $Story->order('story_id DESC')->select();
		$this->assign('storylist',$list);
		$this->display ();
	}
	
	public function storyArticle() {
		//防止页面乱码  
		header ( "Content-Type:text/html; charset=utf-8" );
		$Story = M('Story'); 
		$condition['story_id'] = $_GET['id'];
		$result = $Story->where($condition)->find();
		
		$condition['story_id'] = $_GET['id']-1;
		$pre = $Story->where($condition)->find();
		if(empty($pre)) {
			$this->assign('pre',"没有了");
			$this->assign('pre_url',"");
		} 
		else {
			$this->assign('pre',$pre['title']);
			$this->assign('pre_url',"__URL__/storyArticle/id/".$pre['story_id']);
		}
		
		$condition['story_id'] = $_GET['id']+1;
		$after = $Story->where($condition)->find();
		if(empty($after)) {
			$this->assign('after',"没有了");
			$this->assign('after_url',"");
		} 
		else {
			$this->assign('after',$after['title']);
			$this->assign('after_url',"__URL__/storyArticle/id/".$after['story_id']);
		}
		
		$this->assign('story',$result);
		$this->display ();
	}
}